{extends file="./main.tpl"}
{block name="head"}
<link href="css/user.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function()
{
  $("#contractId").focus();
  $(".addFiles").click(function()
  {
    if($(".addFiles:last").val() == '')
    {
      $("#oneFiles").clone(true).appendTo("#mainDivFiles")
      .find('input[type="file"]').val('').end()
    }
  });
});

function getContract()
{
	var dataString = "contractId=" + $("#contractId").val();
  $.ajax({
    type: "GET",
    url: "getContractDetail.php",
    data: dataString,
    success:function(data){
      $("#register1").html(data); 
     }
});
}

function getInvoiceDetailClient(conObj)
{
	var dataString = "invoiceNo=" + conObj.value;
  $.ajax({
    type: "GET",
    url: "getInvoiceDetailClient.php",
    data: dataString,
    success:function(data){
      $(".setInvoiceDetail").html(data); 
     }
});
}

function getinvoice()
{
	var dataString = "contractId=" + $("#contractId").val();
  $.ajax({
    type: "GET",
    url: "getInvoiceDetailNo.php",
    data: dataString,
    success:function(data){
      $(".setInvoiceDetailNew").html(data); 
   }
}); 
}
</script>
{/block}
{block name="body"}
<!--div class="homeImage"></div-->
<form action="{$smarty.server.PHP_SELF}" method="POST" enctype="multipart/form-data" class="register" style="margin-top:55px;">
<h1 align="center" style="font-size:px; color:#5BA7E9;">{$s_activusers}</h1>
<table border="0" width="100%" align="center" cellpadding="4" cellspacing="0">
<tr>
  <td>Contract No :
  	<label> 
      <select name="contractId" id="contractId" onChange="getContract(); getinvoice(); " AUTOFOCUS>
        <option value="0">All</option>
        {html_options values=$contractsArray.contractId output=$contractsArray.contractNo}
      </select>
    </label>
  </td>
  <td>
  <div class="setInvoiceDetailNew">
  </div>  
  </td>
</tr>
<tbody id="mainDivFiles">
<tr>
  <td colspan="6">
    <div id="register1">
      <h2>Contract Detail</h2>
      <table id="setdata"  align="center">
        <tr>
        	<th class="text-field">Contract Date</th>
        	<th class="text-field">Quntity</th>
        	<th class="text-field">Price</th>
        	<th class="text-field">Value</th>
        	<th class="text-field">Number Of Invoice</th>
        	<th class="text-field">Advace Amount</th>
        	<th class="text-field">Advace Recpit Date</th>
        </tr>
        {section name="sec" loop=$contractArray}
        <tr>
          <td align="center" class="text-field">{$contractArray[sec].contDate}</td>
          <td align="center" class="text-field">{$contractArray[sec].contQty}</td>
          <td align="center" class="text-field">{$contractArray[sec].conPrice}</td>
          <td align="center" class="text-field">{$contractArray[sec].conValue}</td>
          <td align="center" class="text-field">{$contractArray[sec].numOfInvoice}</td>
          <td align="center" class="text-field">{$contractArray[sec].advAmount}</td>
          <td align="center" class="text-field">{$contractArray[sec].advRptDate}</td>
        </tr>
        {/section}
      </table>
    </div>
  </td>
</tr>
<tr>
  <td colspan="6">
    <div class="setInvoiceDetail">
      <table id="setdata"  align="center">
      <h2 align="center">Invoice Detail</h2>
        <tr>
        	<th class="text-field">Invoice No</th>
        	<th class="text-field">Quntity</th>
        	<th class="text-field">Price</th>
        	<th class="text-field">Value</th>
        	<th class="text-field">Date Of Loading</th>
        	<th class="text-field">Vessel</th>
        	<th class="text-field">Etd</th>
        </tr>
        {section name="sec" loop=$invoiceDetailArray}
        <tr>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].invoiceNo}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].qty}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].price}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].value}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].dateOfLoading}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].vessel}</td>
          <td align="center" class="text-field">{$invoiceDetailArray[sec].etdDate}</td>
        </tr>
        {/section}
      </table>
    </div>
  </td>
</tr>
<tr id="oneFiles">
	<td colspan="5" class="text-field">
		<b>Upload File</b><input type="file" name="uploadFile[]" id="files" class="addFiles" multiple />
  </td>
</tr>
</tbody>
<tr>
  <td align="center" colspan="2">
    <input type="submit" name="submit" value="Submit" class="button">
  </td>
</tr>
</table>
</form>
<br /><br />
<form action="download2.php" method="POST" enctype="multipart/form-data" class="register" style="margin-top:55px;">
<table>
  <tr>
    <th align="center" class="text-field">Contract No</th>
    <th align="center" class="text-field">Invoice No</th>
    <th align="center" class="text-field">Uploader</th>
    <th align="center" class="text-field">Download</th>
    <th align="center" class="text-field">Document</th>
    <th align="center" class="text-field">Time</th>
  </tr>
  {section name="sec" loop=$detailArray}
  <tr>
    
    <td align="center" class="text-field">{$detailArray[sec].contractNo}</td>
    <td align="center" class="text-field">{$detailArray[sec].invoiceNo}</td>
    <td align="center" class="text-field">{$detailArray[sec].company}</td>
    <td align="center" class="text-field">
    {section name="sec1" loop=$detailArray[sec][$detailArray[sec].userDocId]}
    <input type="hidden" name="userDocMultiId[]" value="{$detailArray[sec][$detailArray[sec].userDocId][sec1].userDocId}">
    <a href="download1.php?file=./uploadDoc/{$detailArray[sec][$detailArray[sec].userDocId][sec1].uploadFileName}" style="font-size:15px; color:#5BA7E9; text-decoration: none;">Download</a><br/>
    {/section}
    <!--input type="submit" name="submit" value="Submit"-->
    </td>
    <td align="left" class="text-field" NOWRAP >
    {section name="sec1" loop=$detailArray[sec][$detailArray[sec].userDocId]}
    <!--<input type="checkbox" name="Download">-->
    <a href="./uploadDoc/{$detailArray[sec][$detailArray[sec].userDocId][sec1].uploadFileName}" style="font-size:15px; color:#5BA7E9; text-decoration: none;" target="blank">{$detailArray[sec][$detailArray[sec].userDocId][sec1].displayFileName}</a><br/>
    {/section}
    </td>
    <!--<td><a href="download.php?contractId={$detailArray[sec].contractId}&invoiceId={$detailArray[sec].invoiceId}&userId={$userId}" style="font-size:15px; color:#5BA7E9; text-decoration: none;">Download</a><hr></td>-->
    <td align="center" class="text-field">{$detailArray[sec].uploadDateTime}</td>
  </tr>
  {/section}
  <tr>
</tr>
</table>
</form>

{/block}